function NumberOf1Between1AndN_Solution(n)
{
    // write code here
    let res = 0
    let base = 1
    while(n >= base){
      let a = Math.floor(n/base/10) // 前面的数字
      let b = Math.floor(n%base) //后面的数字
      let cur = Math.floor(n/base%10) // 所在位的数字
      if(cur > 1){
        res += (a+1)*base
      }else if(cur === 1){
        res += a*base + b + 1
      }else{
        res += a*base
      }
      base *= 10
    }
    return res
}
module.exports = {
    NumberOf1Between1AndN_Solution : NumberOf1Between1AndN_Solution
};